<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="keywords" content="Yii,bootstrap3,widget,use,例子">
    <meta name="description" content="The usage of yii bootstrap3 widget.">
    <meta name="author" content="chenzhiwei">
    <link rel="icon" href="https://www.yiichina.com/favicon.ico?v=1528501659">
    <link rel="canonical" href="https://getbootstrap.com/docs/3.4/examples/dashboard/">

    <title>Yii bootstrap3 widget guides</title>

    <!-- Bootstrap core CSS -->
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.17/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.17/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/css/boostrap3.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.17/assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.17/assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/yii/default/test">
                <img src="/images/logo.png" alt="yii brand">
            </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-left">
                <li><a href="#">Home</a></li>
                <li><a href="#" class="action">Bootstrap3</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Contact</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar" id="sidebar">
            <ul class="nav nav-sidebar">
                <li class="active"><a href="#">Overview <span class="sr-only">(current)</span></a></li>
                <li><a href="#">Reports</a></li>
                <li><a href="#">Analytics</a></li>
                <li><a href="#">Export</a></li>
                <li>
                    <a href="#" class="collapsed" data-toggle="collapse" data-target="#items" aria-expanded="false" aria-controls="navbar"><span>items</span>
                        <span class="caret"></span>
                    </a>
                    <ul class="nav nav-sidebar collapse level2" id="items">
                        <li><a href="">Nav item</a></li>
                        <li><a href="">Nav item again</a></li>
                        <li><a href="">One more nav</a></li>
                        <li><a href="">Another nav item</a></li>
                        <li>
                            <a href="#"  class="collapsed" data-toggle="collapse" data-target="#items1" aria-expanded="false" aria-controls="navbar"><span>items</span><span class="caret"></span></a>
                            <ul class="nav nav-sidebar collapse level3" id="items1">
                                <li><a href="">Nav item</a></li>
                                <li><a href="">Nav item again</a></li>
                                <li><a href="">One more nav</a></li>
                                <li><a href="">Another nav item</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 ">
            <div class="row">
                <div class="col-sm-10 col-md-10 main">
                    <?php
                    use lvzmen\yii\cms\widgets\markdown\Markdown;

                    $content = <<<CONTENT
# Yii Bootstrap3 小部件
## 目的

Yii给我们提供了丰富的`widget`小部件，其中就有对`bootstrap`的支持，这样我们后端开发人员可以致力于php代码的编写，但是如果对`bootstrap`不熟悉的话，是很难使用这些小部件的，这也将导致比写原生`html`还费劲，本站的主要目的就是介绍`Yii`提供的`bootstrap`小部件的基本用法及扩展用法，让`Yii`的爱好者能够更容易地开发网站。

## Bootstrap小部件

下面就是`YII`提供的所有`bootstrap`小部件了：

基础组件：

- Alert
- Button
- ButtonDropdown
- ButtonGroup
- Carousel
- Collapse
- Dropdown
- InputWidget
- Modal
- Nav
- NavBar
- Progress
- Tabs
- ToggleButtonGroup

高级扩展：

- ActiveField
- ActiveForm

> 注意：高级扩展小部件和`YII`的关联性极强，以模型类为基础进行表单构建，并非简单的`html`代码输出。



## 安装

官方提供的手脚架已经默认引入了composer依赖，因此可以直接使用：

```json
"require": {
    ... ...
    "yiisoft/yii2-bootstrap": "~2.0.0",
},
```

它所在的目录是：

`vendor/yiisoft/yii2-bootstrap/src`

使用方法为：

```php
\yii\bootstrap\Button::widget([
    'label' => 'Login',
    'options' => ['class' => 'btn btn-primary'],
])
```


CONTENT;
                    echo Markdown::widget(["content" => $content]);
                    ?>
                </div>
                <div class="col-sm-2 col-md-2">

                </div>
            </div>

            <footer class="footer vertical-container">
                <p><span>浙ICP备2021007911号</span>Powered by @陈致威</p>
            </footer>
        </div>
    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script>
    window.jQuery || document.write('<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.17/assets/js/vendor/jquery.min.js"><\/script>')
</script>
<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.17/dist/js/bootstrap.min.js"></script>
<!-- Just to make our placeholder images work. Don't actually copy the next line! -->
<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.17/assets/js/vendor/holder.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.17/assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
